--- @param extension Package
--- @param HY HY_Utility
--- @param U Utility
return function(extension, HY, U)
    local hy_kitcho_yachie = General:new(extension, "hy_kitcho_yachie", "chi_k", 4, 4, General.Female)
    local lose_ambition = fk.CreateSkill {
        name = "lose_ambition",
    }
    lose_ambition:addEffect("active", {
        anim_type = "control",
        target_num = 1,
        card_num = 0,
        can_use = function(self, player)
            return not player:isKongcheng() and player:getMark("lose_ambition_disable-turn") == 0
        end,
        card_filter = Util.FalseFunc,
        target_filter = function(self, player, to_select, selected, selected_cards)
            return #selected == 0 and to_select ~= player and not to_select:isKongcheng() and to_select:getMark("lose_ambition_lose-turn") <= 0
        end,
        prompt = function(self, selected, selected_cards)
            return "lose_ambition_prompt"
        end,
        on_use = function(self, room, effect)
            local player = effect.from
            local target = effect.tos[1]
            local pindian = player:pindian({ target }, lose_ambition.name)
            if pindian.results[target].winner == player then
                room:setPlayerMark(target, "@@lose_ambition_mark-turn", 1)
                room:setPlayerMark(player, "lose_ambition_disable-turn", 1)
                if not target:isNude() then
                    local card = room:askToChooseCard(player, {
                        target = target,
                        flag = "he",
                        skill_name = lose_ambition.name
                    })
                    room:obtainCard(player, card, nil, fk.ReasonPrey, player)
                end
            else
                room:setPlayerMark(target, "lose_ambition_lose-turn", 1)
            end
        end,
    })
    lose_ambition:addEffect("prohibit", {
        mute = true,
        prohibit_use = function(self, player, card)
            return player:getMark("@@lose_ambition_mark-turn") > 0
        end,
        prohibit_response = function(self, player, card)
            return player:getMark("@@lose_ambition_mark-turn") > 0
        end,
    })
    lose_ambition:addEffect("atkrange", {
        mute = true,
        within_func = function(self, from, to)
            return to:getMark("@@lose_ambition_mark-turn") > 0 and from ~= to
        end
    })
    lose_ambition:addEffect(fk.TargetConfirmed, {
        mute = true,
        can_refresh = function(self, event, target, player, data)
            return player:getMark("@@lose_ambition_mark-turn") > 0 and data.card and player == target
        end,
        on_refresh = function(self, event, target, player, data)
            local room = player.room
            local useData = room.logic:getCurrentEvent():findParent(GameEvent.UseCard, true).data
            local disresponsiveList = useData.disresponsiveList or {}
            table.insertIfNeed(disresponsiveList, data.to)
            useData.disresponsiveList = disresponsiveList
        end
    })
    local lure_impel = fk.CreateSkill {
        name = "lure_impel",
    }
    lure_impel:addEffect(fk.EventPhaseStart, {
        anim_type = "offensive",
        can_trigger = function(self, event, target, player)
            local room = player.room
            -- check timing
            if target ~= player or target.phase ~= Player.Finish or not player:hasSkill(lure_impel.name) then
                return false
            end
            -- check cards
            player.tag["lure_impel_cards"] = table.map(table.filter(HY.GetTurnDiscardPile(room), function(card)
                return card.is_damage_card
            end), function(card)
                return card.id
            end)
            if #player.tag["lure_impel_cards"] == 0 then
                return false
            end
            -- check targets
            for _, t in ipairs(room:getOtherPlayers(player)) do
                if #table.filter(room.alive_players, function(_t, _, _)
                        return t:inMyAttackRange(_t)
                    end) > 0 then
                    return true
                end
            end
        end,
        on_cost = function(self, event, target, player, data)
            if player.id < 0 then
                return false
            end
            local room = player.room
            HY.ReplaceHandCardToTempNew(player, player.tag["lure_impel_cards"])
            local success, dat = room:askToUseActiveSkill(player, {
                skill_name = "lure_impel_active",
                prompt = "lure_impel_active_prompt",
            })
            event:setCostData(self, dat)
            HY.ReverseHandCardFromTempNew(player)
            player.tag["lure_impel_cards"] = {}
            return success
        end,
        on_use = function(self, event, target, player, data)
            local room = player.room
            local card = Fk:getCardById(event:getCostData(self).cards[1])
            local target1 = event:getCostData(self).targets[1]
            local target2 = event:getCostData(self).targets[2]
            room:moveCards({
                ids = event:getCostData(self).cards,
                toArea = Card.PlayerHand,
                to = target1,
                moveReason = fk.ReasonGive,
                proposer = player,
                skillName = lure_impel.name,
            })
            local attack = false
            if target1:canUseTo(card, target2, { bypass_distances = true, bypass_times = true }) then
                attack = room:askToSkillInvoke(target1, {
                    skill_name = lure_impel.name,
                    prompt = "lure_impel_attack::" .. target2.id .. ":" .. card:toLogString()
                })
            end
            if attack then
                room:useCard({
                    from = target1,
                    tos = { target2 },
                    card = card
                })
            else
                if #table.filter(target1.player_cards[Player.Hand], function(id)
                        return not player:prohibitDiscard(Fk:getCardById(id))
                    end) + #table.filter(target1.player_cards[Player.Equip], function(id)
                        return not player:prohibitDiscard(Fk:getCardById(id))
                    end) <= 2 then
                    local cards = table.connect(table.filter(target1.player_cards[Player.Hand], function(id)
                        return not player:prohibitDiscard(Fk:getCardById(id))
                    end), table.filter(target1.player_cards[Player.Equip], function(id)
                        return not player:prohibitDiscard(Fk:getCardById(id))
                    end))
                    if #cards > 0 then
                        room:throwCard(cards, lure_impel.name, target1, target1)
                    end
                else
                    room:askToDiscard(target1, {
                        min_num = 2,
                        max_num = 2,
                        include_equip = true,
                        skill_name = lure_impel.name,
                        cancelable = false,
                    })
                end
            end
        end,
    })
    local lure_impel_active = fk.CreateSkill {
        name = "lure_impel_active",
    }
    lure_impel_active:addEffect("active", {
        mute = true,
        card_num = 1,
        card_filter = function(self, player, to_select, selected)
            return #selected == 0 and table.contains(player:getTableMark("#tempMove"), to_select)
        end,
        expand_pile = function(self, player)
            return player:getTableMark("#tempMove")
        end,
        target_num = 2,
        target_filter = function(self, player, to_select, selected, selected_cards)
            local room = Fk:currentRoom()
            if #selected == 0 then
                local targetIds = {}
                for _, t in ipairs(room.alive_players) do
                    if #table.filter(room.alive_players, function(_t, _, _)
                            if t:inMyAttackRange(_t) then
                                return true
                            end
                        end) > 0 and t ~= player then
                        table.insert(targetIds, t.id)
                    end
                end
                return table.contains(targetIds, to_select.id)
            elseif #selected == 1 then
                local skill_target = selected[1]
                local attackIds = table.map(table.filter(room.alive_players, function(t, _, _)
                    if skill_target:inMyAttackRange(t) then
                        return true
                    end
                end), Util.IdMapper)
                return table.contains(attackIds, to_select.id)
            end
        end,
        prompt = function(self, player, selected_cards, selected_targets)
            return "lure_impel_active_prompt"
        end,
        target_tip = function(self, player, to_select, selected, selected_cards, card, selectable, extra_data)
            local room = Fk:currentRoom()
            if #selected == 0 then
                local targetIds = {}
                for _, t in ipairs(room.alive_players) do
                    if #table.filter(room.alive_players, function(_t, _, _)
                            if t:inMyAttackRange(_t) then
                                return true
                            end
                        end) > 0 and t ~= player then
                        table.insert(targetIds, t.id)
                    end
                end
                if table.contains(targetIds, to_select.id) then
                    return "lure_impel_active_gain"
                end
            elseif #selected == 1 then
                if to_select == selected[1] then
                    return "lure_impel_active_gain"
                else
                    local skill_target = selected[1]
                    local attackIds = table.map(table.filter(room.alive_players, function(t, _, _)
                        if skill_target:inMyAttackRange(t) then
                            return true
                        end
                    end), Util.IdMapper)
                    if table.contains(attackIds, to_select.id) then
                        return "lure_impel_active_target"
                    end
                end
            else
                if to_select == selected[1] then
                    return "lure_impel_active_gain"
                elseif to_select == selected[2] then
                    return "lure_impel_active_target"
                end
            end
        end
    })
    extension:loadSkillSkels { lose_ambition, lure_impel, lure_impel_active }
    hy_kitcho_yachie:addSkills { "lose_ambition", "lure_impel" }
    Fk:loadTranslationTable {
        ["hy_kitcho_yachie"] = "吉吊八千慧",
        ["#hy_kitcho_yachie"] = "阴狠之智首",
        ["illustrator:hy_kitcho_yachie"] = "chan",
        ["designer:hy_kitcho_yachie"] = "黑曜人形",
        ["cv:hy_kitcho_yachie"] = "",

        ["lose_ambition"] = "丧志",
        [":lose_ambition"] = "每回合每角色限一次，出牌阶段，你可以拼点：若你赢，你获得该角色一张牌且本回合“丧志”失效，然后其无法使用或打出牌且视为在其以外角色攻击范围内直到本回合结束。",
        ["@@lose_ambition_mark-turn"] = "丧志",
        ["lose_ambition_prompt"] = "丧志：选择一名角色拼点",

        ["lure_impel"] = "诱驱",
        [":lure_impel"] = "结束阶段，你可以将一张于本回合进入弃牌堆的伤害类牌交给一名其他角色并令其选择一项：1.对其攻击范围内你指定的一名角色使用此牌；2.弃置两张牌（不足则全弃）。",
        ["lure_impel_active_prompt"] = "诱驱：令一名角色对另一名角色使用牌",
        ["lure_impel_attack"] = "诱驱：对%dest使用%arg，或弃置两张牌",
        ["lure_impel_active"] = "诱驱",
        ["lure_impel_active_gain"] = "获得牌",
        ["lure_impel_active_target"] = "被使用牌",
    }
end
